import Axios from './Axios'
import { AxiosInstance } from './types'
function createInstance(): AxiosInstance {
  let context: Axios = new Axios() // this指针 上下文
  // request方法里面的this永远指向context也就是 new Axios()
  let instance = Axios.prototype.request.bind(context)
  // 把Axios类实例上的方法和类的原型上的方法都拷贝到instance上，也就是request方法
  instance = Object.assign(instance, Axios.prototype, context)
  return instance as AxiosInstance
}
const axios = createInstance()
export default axios
export * from './types'